import 'package:flutter/material.dart';

class Bottom extends StatefulWidget {
  Bottom({Key key, this.scjr}) : super(key: key);
  final scjr;

  @override
  _BottomState createState() => _BottomState();
}

class _BottomState extends State<Bottom> {
  Color _mainColor = Color(0xFFc55144);
  Color _bgColor = Color(0xFFede7de);

  rowWidget(name, time, yi, ji) {
    return Container(
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            color: _mainColor,
            width: 2,
            style: BorderStyle.solid,
          ),
          right: BorderSide(
            color: _mainColor,
            width: 2,
            style: BorderStyle.solid,
          ),
          left: BorderSide(
            color: _mainColor,
            width: 2,
            style: BorderStyle.solid,
          ),
        ),
      ),
      child: Row(
        children: [
          Container(
            width: 90,
            padding: EdgeInsets.all(10),
            decoration: BoxDecoration(
              border: Border(
                right: BorderSide(
                  color: _mainColor,
                  width: 2,
                  style: BorderStyle.solid,
                ),
              ),
            ),
            child: Column(
              children: [
                Text(
                  name,
                  style: TextStyle(
                    color: _mainColor,
                    fontSize: 16,
                    fontWeight: FontWeight.w600,
                  ),
                ),
                Text(
                  time,
                  style: TextStyle(
                    color: _mainColor,
                    fontSize: 11,
                    fontWeight: FontWeight.w600,
                  ),
                ),
              ],
            ),
          ),
          SizedBox(width: 10),
          Expanded(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      '【宜】',
                      style: TextStyle(
                        color: Color(0xFF238F60),
                        fontSize: 11,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                    Expanded(
                      child: Text(
                        yi,
                        style: TextStyle(
                          color: _mainColor,
                          fontSize: 11,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ),
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      '【忌】',
                      style: TextStyle(
                        color: Color(0xFFEE1000),
                        fontSize: 11,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                    Expanded(
                      child: Text(
                        ji,
                        style: TextStyle(
                          color: _mainColor,
                          fontSize: 11,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
          SizedBox(width: 5)
        ],
      ),
    );
  }

  renderRowWidget(data) {
    List<Widget> list = [];
    for (var i = 0; i < data.length; i++) {
      var item = data[i];
      list.add(rowWidget(item['cnTime'], item['time'], item['yi'], item['ji']));
    }
    return list;
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Container(
          width: MediaQuery.of(context).size.width,
          padding: EdgeInsets.all(10),
          decoration: BoxDecoration(
            color: _mainColor,
          ),
          child: Center(
            child: Text(
              '时辰凶吉',
              style: TextStyle(
                color: _bgColor,
                fontSize: 16,
                fontWeight: FontWeight.w600,
              ),
            ),
          ),
        ),
        Column(children: renderRowWidget(widget.scjr)),
        SizedBox(height: 40)
      ],
    );
  }
}
